<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="../../js/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../js/jquery-migrate-1.0.0.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
    	
       $(function(){
       	 $("#btn").toggle(function(){ //此方法1.9后需要migrate插件
       	 	$("#myDiv").css("background-color","green");
       	 },function(){
       	 	$("#myDiv").css("background-color","red");
       	 })
       })
        

    </script>
</head>
<body>

    <input id="btn" type="button" value="事件切换">
    <br />
    <div id="myDiv" style="width:300px;height:300px;background:pink">
        点击按钮变成绿色，再次点击红色
    </div>
</body>
</html>

